<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/3/22
 * Time: 12:28
 */

namespace App\Http\Controllers\MiniProgramAdmin;


use App\Http\Controllers\BaseController;
use App\Http\Logics\MiniProgramAdmin\OrderLogic;
use App\Http\Traits\OrderTrait;

class OrderController extends BaseController
{
    use OrderTrait;

    /**
     * @SWG\Get(
     *     path="/order/list",
     *     tags={"Order"},
     *     description="订单列表",
     *     operationId="deliver",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="cafe_id",
     *         in="query",
     *         description="咖啡馆ID",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_id",
     *         in="query",
     *         description="合作者ID",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="limit",
     *         in="query",
     *         description="分页大小",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="status",
     *         in="query",
     *         description="订单状态",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getOrderList()
    {
        $loginSession = $this->loginSession;
        $cafe_id = $this->cafe_id;
        $partner_id = $this->partner_id;
        $limit = $this->limit;
        $status = $this->status;
        $data = [
            'loginSession' => $loginSession,
            'cafe_id' => $cafe_id,
            'partner_id' => $partner_id,
            'limit' => $limit,
            'status' => $status
        ];
        $response = OrderLogic::getOrderList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/order/deliver",
     *     tags={"Order"},
     *     description="订单发货",
     *     operationId="deliver",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="order_id",
     *         in="query",
     *         description="订单ID",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="courier_number",
     *         in="query",
     *         description="订单号",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function deliver()
    {
        $order_id = $this->order_id;
        $courier_number = $this->courier_number;
        $data = [
            'order_id' => $order_id,
            'courier_number' => $courier_number
        ];
        $response = OrderLogic::deliver($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/order/dhcx",
     *     tags={"Order"},
     *     description="单号查询",
     *     operationId="dhcx",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="courier_number",
     *         in="query",
     *         description="物流单号",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function dhcx()
    {
        $courier_number = $this->courier_number;
        $data = [
            'courier_number' => $courier_number
        ];
        $response = OrderLogic::dhcx($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/order/refund",
     *     tags={"Order"},
     *     description="订单退款",
     *     operationId="refund",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="order_id",
     *         in="query",
     *         description="订单编号",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function refund()
    {
        $order_id = $this->order_id;
        $data = [
            'order_id' => $order_id
        ];
        $response = OrderLogic::refund($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}